<?php
$reserveListStr = Yii::t('BWeSport', 'Reserve list items');
$locationSearchStr = Yii::t('BWeSport', 'Location Search');
$keywordSearchStr = Yii::t('BWeSport', 'KeyWord Search');
$eventNameStr = Yii::t('BWeSport', 'Event Name');
$eventTypeStr = Yii::t('BWeSport', 'Event Type');
$startTimeStr = Yii::t('BWeSport', 'Start Time');
$endTimeStr = Yii::t('BWeSport', 'End Time');
$operateStr = Yii::t('BWeSport', 'Operate');
$modifyStr = Yii::t('BWeSport', 'Modify');
$newAddStr = Yii::t('BWeSport', 'New Add');
$deleteStr = Yii::t('BWeSport', 'Delete');
$app = Blyn::app()->getActiveApp();
?>

<script type="text/javascript">
    $(document).ready(function() {
        $("#selectAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "findEventForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<legend><h4><?php echo '活动列表'; ?></h4></legend>
<fieldset>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>
                    <input type="checkbox"  id="selectAll"> 
                </th>
                <th><?php echo $eventNameStr; ?></th>
                <th><?php echo $eventTypeStr; ?></th>
                <th><?php echo $operateStr; ?></th>
            </tr> 
        </thead>
        <tbody>
            <?php foreach ($eventList as $event) { ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="<?php echo $event->id; ?>"> 
                        </label></td>
                    <td> <?php echo $event->getName(); ?> </td>
                    <td> <?php echo $event->getType()->getFullName('|'); ?> </td>    
                    <td>
                        <div class="row-fluid">                         
                            <?php
                            echo $control->getAjaxLink(array('name' => $modifyStr, 'id' => 'showAddEvent'), array(
                                'eventId' => $event->id,
                                //'ajaxContainerId' => 'myModal',
                                'htmlOptions' => array(
                                    'enctype' => 'multipart/form-data'),
                                    //'ajaxOptions' => array(
                                    //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
                            ));
                            ?>  
                             &nbsp;|&nbsp;
                            <?php
                                $eventTypeName = $event->getGroup(array('parent' => BWEventGroup::EVENT_TYPE))->name;
                                switch($eventTypeName)
                                {
                                    case 'translate': $messageListView = 'showTranslationList'; break;
                                    case 'note': $messageListView = 'showTravelNotesList'; break;
                                    case 'food': $messageListView = 'showTravelFoodList'; break;
                                    case 'info': $messageListView = 'showTravelInfoList'; break;
                                    case 'ad': $messageListView = 'showTravelAdList'; break;
                                    default : $messageListView = 'showTranslationList';
                                }
                            echo $control->getAjaxLink(array('name' => '管理', 'id' => 'showMessageList'), array('eventId' => $event->id,'messageListView'=>$messageListView,'htmlOptions' => array('enctype' => 'multipart/form-data')));
                            ?>
                        </div>                      
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>

    <div class="row-fluid">
        <?php
        echo $control->getAjaxLink(array('name' => $newAddStr, 'id' => 'showAddEvent'), array(
            'eventId' => 0,
            //'ajaxContainerId' => 'myModal',
            'htmlOptions' => array(
                'enctype' => 'multipart/form-data',
                'class' => 'btn'),
                //'ajaxOptions' => array(
                //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
        ));
        ?>
        <?php
        echo $control->getAjaxLink(array('name' => $deleteStr, 'id' => 'deleteEvent'), array(
            'htmlOptions' => array(
                'class' => 'btn',
                'enctype' => 'multipart/form-data')));
        ?>
    </div>   
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>

    <div><input type="hidden" name="curPageNo" value="1"></div>

    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>
    <?php $this->endWidget(); ?>


